package com.bingbaihanji.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.bingbaihanji.mapper.AreaMapper;
import com.bingbaihanji.pojo.Area;
import com.bingbaihanji.service.AreaService;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;

import java.util.List;

/**
 * @author 冰白寒祭
 * @date 2024-04-05 22:33:57
 * @description //TODO
 */
@ApplicationScoped
public class AreaServiceImpl implements AreaService {
    @Inject
    AreaMapper areaMapper;

    public List<Area> list() {
        Wrapper<Area> queryWrapper = new QueryWrapper<>();
        List<Area> areas = areaMapper.selectList(queryWrapper);
        for (Area area : areas) {
            System.out.println(area);
        }
        return areas;
    }

    @Override
    public Area getById(Integer id) {

        Area area = areaMapper.selectById(id);
        System.out.println(area);
        return area;
    }

    @Override
    public int AreaAdd(Area area) {
        return areaMapper.insert(area);
    }

    @Override
    public int AreaDelete(Integer id) {
        return areaMapper.deleteById(id);
    }

    @Override
    public int AreaUpdate(Area area) {
        return areaMapper.updateById(area);
    }

}
